package com.example.Dao;

import com.example.Domain.Student;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;

@Mapper
@Repository
public interface StudentMapper {
    // 注册学生
    @Insert("INSERT INTO students (username, password, major, grade, classes, tel) " +
            "VALUES (#{username}, #{password}, #{major}, #{grade}, #{classes}, #{tel})")
    int AddStudent(Student student);

    // 删除学生
    @Delete("DELETE FROM students WHERE id = #{id}")
    int DeleteStudent(int id);

    // 查询单个学生
    @Select("SELECT * FROM students WHERE username = #{username}")
    Student SelectStudentById(String username);

    // 查询所有学生
    @Select("SELECT * FROM students")
    List<Student> SelectAllStudent();

    // 根据用户名查询学生
    @Select("SELECT * FROM students WHERE username = #{username}")
    Student SelectStudentByUsername(String username);
}